package cn.dm.service;

import cn.dm.common.IdWorker;
import cn.dm.mapper.DmTradeMapper;
import cn.dm.pojo.DmOrder;
import cn.dm.pojo.DmTrade;
import cn.dm.vo.DmItemMessageVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Calendar;

/**
 * Created by zezhong.shang on 18-5-15.
 */
@RestController
public class RestDmTradeService {
    private static final Logger logger = LoggerFactory.getLogger(RestDmTradeService.class);
     @Resource
     private DmTradeMapper dmTradeMapper;
     @Resource
     private RabbitTemplate rabbitTemplate;

    @RequestMapping(value = "/insertTrade",method = RequestMethod.POST)
    public Integer insertTrade(@RequestBody DmItemMessageVo dmItemMessageVo) throws Exception {
        DmTrade qgTrade = new DmTrade();
        qgTrade.setId(IdWorker.getId().toString());
        qgTrade.setAmount(dmItemMessageVo.getAmount());
        qgTrade.setCreatedTime(Calendar.getInstance().getTime());
        qgTrade.setOrderNo(dmItemMessageVo.getOrderNo());
        qgTrade.setPayMethod(1);
        qgTrade.setTradeNo(dmItemMessageVo.getTradeNo());
        return dmTradeMapper.insertDmTrade(qgTrade);
    }
}
